﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using ATest.Bll;

namespace ATest.Tests.MockObjects
{
    public class MockTest : Moq.Mock<Test>
    {
        public MockTest(int id, string name, DateTime created, string createdBy, DateTime lastUpdated, string lastUpdatedBy)
        {
            this.Setup(x => x.Id).Returns(id);
            this.SetupProperty(x => x.Name, name);
            this.Setup(x => x.Created).Returns(created);
            this.Setup(x => x.CreatedBy).Returns(createdBy);
            this.Setup(x => x.LastUpdated).Returns(lastUpdated);
            this.Setup(x => x.LastUpdatedBy).Returns(lastUpdatedBy);
        }

        public static List<MockTest> CreateList(int count)
        {
            var tmp = new List<MockTest>();
            while (tmp.Count < count)
            {
                tmp.Add(
                    new MockTest(
                        tmp.Count + 1,
                        string.Concat("Test Name ", tmp.Count + 1),
                        DateTime.Parse("24/10/1975 12:55").ToUniversalTime().AddDays(tmp.Count),
                        string.Concat("Created By ", tmp.Count + 1),
                        DateTime.Parse("24/11/1975 12:55").ToUniversalTime().AddDays(tmp.Count),
                        string.Concat("updated By ", tmp.Count + 1) 
                        )
                    );
            }
            return tmp;
        }

        public void SetQuestions(IEnumerable<Question> questions)
        {
            var tmp = new EntitySet<Question>();
            tmp.Assign(questions);
            Setup(m => m.Questions).Returns(tmp);
        }
    }
}
